package com.rsk.dao.extend;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author mry
 * 扩展类
 */
@Component
public class SysCompanyTypesExtend {

    public Map<String, Object> selectCourseCategoryByPage(String typeName){
        // 拼接SQL语句
        StringBuilder sql = new StringBuilder("SELECT id,type_name FROM sys_company_types where is_del = 0");

        // 查询需要的参数，先存进Map
        StringBuilder paramSql = new StringBuilder();
        Map<String, Object> paramMap = new HashMap<String, Object>();
        if (typeName != null && !typeName.isEmpty()) {
            paramSql.append(" and type_name like :typeName");
            paramMap.put("typeName", "%" + typeName + "%");
        }
        //排序
        StringBuilder orderSql = new StringBuilder();
        orderSql = orderSql.append(" order by sort");

        Map<String, Object> returnMap = new HashMap<String, Object>();
        returnMap.put("sql", sql.append(paramSql).append(orderSql));
        returnMap.put("paramMap", paramMap);
        return returnMap;
    }
}
